using System.Collections;
using System.Collections.Generic;

namespace Edge.Common.DataUtils
{
    public class HashtableBehaviorlDictionary<TKey, TValue> : IDictionary<TKey, TValue>
    {
        Dictionary<TKey, TValue> argr = null;


        public HashtableBehaviorlDictionary(IEqualityComparer<TKey> comparer)
        {
            argr = new Dictionary<TKey, TValue>(comparer);
        }


        public HashtableBehaviorlDictionary()
        {
            argr = new Dictionary<TKey, TValue>();
        }


        public bool ContainsKey(TKey key)
        {
            return argr.ContainsKey(key);
        }

        public void Add(TKey key, TValue value)
        {
            argr.Add(key, value);
        }

        public bool Remove(TKey key)
        {
            return argr.Remove(key);
        }

        public bool TryGetValue(TKey key, out TValue value)
        {
            return argr.TryGetValue(key, out value);
        }

        public TValue this[TKey key]
        {
            get
            {
                if (!argr.ContainsKey(key))
                    return default(TValue);
                return argr[key];
            }
            set { argr[key] = value; }
        }

        public ICollection<TKey> Keys
        {
            get { return argr.Keys; }
        }

        public ICollection<TValue> Values
        {
            get { return argr.Values; }
        }


        public void Add(KeyValuePair<TKey, TValue> item)
        {
            ((ICollection<KeyValuePair<TKey, TValue>>)argr).Add(item);
        }

        public void Clear()
        {
            argr.Clear();
        }

        public bool Contains(KeyValuePair<TKey, TValue> item)
        {
            return ((ICollection<KeyValuePair<TKey, TValue>>)argr).Contains(item);
        }

        public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
        {
            ((ICollection<KeyValuePair<TKey, TValue>>)argr).CopyTo(array, arrayIndex);
        }

        public bool Remove(KeyValuePair<TKey, TValue> item)
        {
            return ((ICollection<KeyValuePair<TKey, TValue>>)argr).Remove(item);
        }

        public int Count
        {
            get { return argr.Count; }
        }

        public bool IsReadOnly
        {
            get { return ((ICollection<KeyValuePair<TKey, TValue>>)argr).IsReadOnly; }
        }

        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
        {
            return argr.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return ((IEnumerable)argr).GetEnumerator();
        }
    }
}